﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    //
    public class YGRABDOCData : BaseFunction
    {
        ApplicationBase app
        {
            get
            {
               return ApplicationBase.Instance;
            }
        }
        INTEXDBC INTEXDBC
        {
            get
            {
                return app.INTEXDBC;
            }
        }
        public INTEXBL INTEXBL
        {
            get
            {
                return app.INTEXBL;
            }
        }
        SETINTEXDB INTEXDB = new SETINTEXDB();
        public YGRABDOCData()
            : base()
        {

        }
        public SETINTEXDB BuildData(string client, string KRS, string LFD)
        {
            DataSet SResult = new DataSet();
            SETINTEXDB SReturn = new SETINTEXDB();
           
     
                try
            { 
                SResult = INTEXBL.QueryABK(MANDANT, KRS, LFD);
                if (SResult.Tables.Contains("ABPOS"))
                {
                    foreach (DataRow row in SResult.Tables["ABPOS"].Rows)
                    {
                        row["ABPART"] =Helper.Convert8859P1ToGB2312(row["ABPART"].ToString());
                    }
                }
                SReturn.Merge(SResult); 
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return SReturn;
        }         

    }
}